<?php
namespace app\common\service;

use app\common\exception\BackErrorException;
use app\common\model\WechatUser as WechatUserModel;
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/10/15 0015
 * Time: 19:54
 */
class WechatUserService {
    public function getList($page,$pageSize,$where){
        $start = ($page - 1) * $pageSize;
        $count = WechatUserModel::where($where)->count();
        $list = WechatUserModel::where($where)->order('id','desc')->limit($start,$pageSize)->select();
        return ['total'=>$count,'list'=>$list];
    }


    public function create($data){
        return WechatUserModel::create($data);
    }

    public function update($data,$id){
        return WechatUserModel::update($data,['id'=>$id]);
    }

    public function remove($id){
        throw new BackErrorException("不能删除用户");
    }

    public function getOne($id){
        return WechatUserModel::where(['id'=>$id])->find();
    }
}